package com.xuanyue.componentbasics.result;


import lombok.Data;

@Data
public class Result<T> {

    /* 状态码 */
    private Integer code;
    /* 消息 */
    private String message;
    /* 是否成功 */
    private Boolean success;

    private T data;

    public static <T> Result<T> success( T data ){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setData( data );
        result.setSuccess( true );
        return result;
    }

    public static Result fail( Integer code, String message ){
        Result result = new Result();
        result.setCode( code );
        result.setMessage( message );
        result.setSuccess( false );
        return result;
    }

}
